#include <iostream>

void swap(int &a, int &b)
{
    int temp = a;
    a = b;
    b = temp;
}

void show(const int &a)//常引用 减少内存拷贝
{
    std::cout<<a<<std::endl;
}

int main()
{
    #if 1
    int a = 10;
    int &b = a;//引用定义必须初始化，初始化以后不再改变朝向

    int c = 20;
    b = c;
    std::cout<<b<<","<<a<<std::endl;

    #else

    // int a = 10;
    // int* b = &a;

    // int c = 20;
    // b = &c;
    // std::cout<<*b<<","<<a<<std::endl;
    #endif

    int a1= 10;
    int a2 = 20;
    swap(a1,a2);
    std::cout<<a1<<","<<a2<<std::endl;

    show(10);
    return 0;
}